<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.UserGroup,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.utils.ConfigManager,
				java.util.ArrayList"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/purchaseOrderReceipt.do"/>

<%
    int i = 0;
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String functionalityString = Functionality.PURCHASE_ORDER;
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script language="javascript">
window.onload = init;
var errors = '';
var errorIndex;
var prevPrice = 0.0;
var selectedTaxPercent = 0.0;


function lotDataEntry(index, purchaseOrderLineItemNumber)
{
    errorIndex.innerHTML = '';
    if (document.purchaseOrderReceiptForm[ 'receivingLineItemList[' + index + '].selected' ].checked == true)
    {
        newWindow = window.open('<%=chipTracContext%>/purchaseOrderReceipt.do?action=purchaseOrderLineItemLotEntry&purchaseOrderLineItemNumber='+purchaseOrderLineItemNumber+'&index='+index,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=580,height=600,resizable=yes,screenX=5,screenY=55,left=50,top=40');
		newWindow.focus();
	}
	else
	{
  		var error		= document.getElementById( "lineItemErrors" );
	    error.innerHTML	= "Please Select the check box for Lot Entry" ;
	}
}
function openLotDataEntry( )
{
    newWindow = window.open('<%=chipTracContext%>/purchaseOrderReceipt.do?action=purchaseOrderLineItemLotEntry&openRecevingLineItemLotEntry=true','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=580,height=600,resizable=yes,screenX=5,screenY=55,left=50,top=40');
    newWindow.focus();
}

var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}

function selectInventory( x )
{
	if ( document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ x +'].selected' ].checked == true )
	{
		//document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ x +'].shippedQty'].disabled = false;
	}
	else
	{
		document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ x + '].shippedQty'].disabled = true;
		document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ x + '].shippedQty'].value	= 0;
        document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ x + '].extendedCost'].value = 0;
	}
    calculateTotals();    
}

function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function confirmPO()
{
    errorIndex = document.getElementById( "errorIndex" );
    var isAnyLineItemSelected = false;
    <logic:lessEqual value="0" property="receipt_id" name="purchaseOrderReceiptForm">
    var receiptNumberCtrl = document.purchaseOrderReceiptForm['receipt_Number'];
    if( receiptNumberCtrl.value.trim() == '')
    {
        receiptNumberCtrl.focus();
        errorIndex.innerHTML = "<li> Please enter Receipt Number";
        return;
    }
    else
    {
        if( chkSalesOrderNoBegin(receiptNumberCtrl.value.trim()) )
        {
            receiptNumberCtrl.focus();
            errorIndex.innerHTML = "<li>Receipt Number should not start with special characters ";
            return;
        }
        else
        if( ! chkSalesOrderNo(receiptNumberCtrl.value.trim()) )
        {
            receiptNumberCtrl.focus();
            errorIndex.innerHTML = "<li>Please enter valid Receipt Number";
            return;
        }
    }
    </logic:lessEqual>
    if ( lineItemLength == 0 )
    {

        errorIndex.innerHTML = "<li>Please Add Receipt Lot Information"
        return;
    }
    for( var i = 0; i < lineItemLength; i++ )
	{
        var selected = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].selected'];
        if( selected.checked == true )
        {
            isAnyLineItemSelected = true;
            var errors = '';
            var tmpErrMsg = '';
            var receivedDate = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].receivedDate'].value;
            var receivedQty = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].shippedQty'];
            var unitCost = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].unitCost'].value;
            var freight = document.purchaseOrderReceiptForm[ 'frieght'].value;
            var tradeDiscount = document.purchaseOrderReceiptForm[ 'trade_Discount'].value;
            var misc = document.purchaseOrderReceiptForm[ 'miscellaneous'].value;
            var tax = document.purchaseOrderReceiptForm[ 'tax'].value;
            var poTaxType = document.purchaseOrderReceiptForm[ 'poTaxType'].value;
            var descriptionLength = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].description'].value.length;


            if(descriptionLength > 200 )
            {
                errors = errors + "<li> Description Should be Maximum of 200 Characters for LineItem "+eval(i+1);
            }
            if ( chkDate( receivedDate, "Received date","n") == false )
            {
                errors = errors + errMsg+" for LineItem "+eval(i+1);
            }
            tmpErrMsg = checkQuantity( receivedQty, "Received Quantity" );
            if( tmpErrMsg != '' )
            {
                errors = errors + tmpErrMsg +" for LineItem "+eval(i+1);
            }

            /*tmpErrMsg = checkAmount(unitCost, "Unit Cost");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }*/
            tmpErrMsg = checkAmount(freight, "Freight Amount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            tmpErrMsg = checkAmount(tradeDiscount, "Trade Discount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            tmpErrMsg = checkAmount(misc, "Miscellaneous Amount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            if( poTaxType == "-1")
            {
                var newState = document.purchaseOrderReceiptForm['newPoState'].value;
                var newTax = document.purchaseOrderReceiptForm['newPoTax'].value;
                if( (newState.length == 0 || newState == '') &&  (newTax.length == 0 || newTax == ''))
                {
                     errors = errors + "<li> Please enter values for New State and New Tax";
                }
                else if( newState.length == 0 || newState == '')
                {
                    errors = errors + "<li>  Please enter New State ";
                }
                else if( newTax.length == 0 || newTax == '')
                {
                    errors = errors + "<li>  Please enter New Tax ";
                }


                if(  newState.length != 0 && newState != '')
                {
<%--                is_Sp_Characters_frieght returns false if newTax has [a to z] OR [A to Z] OR [_ OR -] OR [space]--%>
                    if( !(is_Sp_Characters_State(newState)) )
                    {
                      errors = errors + "<li>  Please enter a valid state ";
                    }
                }
                if( newTax.length != 0 && newTax != '')
                {
                    var decimalPointCount = 0;
<%--                is_Sp_Characters_frieght returns false if newTax has [a to z] OR [A to Z] OR [_ OR -] OR [space]--%>
                    if( !(is_Sp_Characters_frieght(newTax)) )
                    {
                       errors = errors + "<li> New Po tax should be a number";
                    }
                    for(var charPos = 0; charPos < newTax.length;charPos++)
                    {
                        var curChar = newTax.charAt(charPos);
                        if( curChar == '.' )
                        {
                            decimalPointCount++;
                            if(decimalPointCount > 1 )
                            {
                                errors = errors  + "<li> New Tax should be valid number ";
                                break;
                            }
                        }
                    }
                    if( newTax <= 0.00 )
                    {
                        errors = errors + "<li> New Tax Should be greater than Zero (0) </li>";

                    }
                }
            }
            if( errors != '' )
            {
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
        }
    }

    if ( isAnyLineItemSelected == false )
    {
        errorIndex.innerHTML = "<li> Please select atleast one LineItem"
        errorIndex.focus();
        return;
    }
	enableFields();
    document.purchaseOrderReceiptForm.action='<%=chipTracContext%>/purchaseOrderReceipt.do?action=confirm' ;
	document.purchaseOrderReceiptForm.submit();
}
function enableFields()
{
    for( var i = 0; i < lineItemLength; i++ )
	{
		//document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].shippedQty'].disabled = false;
		document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].selected'].disabled = false;
        document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].extendedCost'].disabled = false;
        document.purchaseOrderReceiptForm[ 'sub_total'].disabled = false;
        document.purchaseOrderReceiptForm[ 'tax'].disabled = false;
        document.purchaseOrderReceiptForm[ 'total'].disabled = false;
	}
}
function checkQuantity(qty,name)
{
   if(!isInteger(qty.value))
    {
        return "<li>  Please enter a valid "+name;
    }
    else if(qty.value == 0)
    {
        return "<li>  Please enter a valid "+name;
    }
    else if((qty.value).length > 6)
    {
        return "<li>  Please enter a valid "+name+" (should not allow more than 6 digits)";
    }
    return '';
}

function checkAmount(fieldValue,fieldName )
{
    if ( (checkFloat( fieldValue, fieldName, 'n' ) == false) )
    {
        return errMsg;
    }
    if(check_char_position4(fieldValue) || (is_Sp_Characters_frieght(fieldValue) == false)  )
    {
        return "Please enter a valid "+fieldName;
    }
    if( fieldValue.length >= 8 )
    {
        var index = fieldValue.indexOf(".");
        if( index == -1 || index > 7 )
        {
            return "Please enter a valid "+fieldName+" (amount should be in XXXXXXX.XX format)";
        }
    }
    return '';
}

function calculateTotals()
{
    errorIndex.innerHTML = "";
    var subTotal = 0.00;
    var freight = document.purchaseOrderReceiptForm[ 'frieght'];
    if( freight.value.trim() == '' )
    {
        errors = "<li> Please enter valid Freight"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var tradeDiscount = document.purchaseOrderReceiptForm[ 'trade_Discount'];
    if( tradeDiscount.value.trim() == '' )
    {
        errors = "<li> Please enter valid Trade Discount"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var misc = document.purchaseOrderReceiptForm[ 'miscellaneous'];
    if( misc.value.trim() == '' )
    {
        errors = "<li> Please enter valid Miscellaneous"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var tax = document.purchaseOrderReceiptForm[ 'tax'];
    var total = document.purchaseOrderReceiptForm[ 'total'];

    for ( var i=0; i<lineItemLength; i++)
    {
        var selected = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].selected'];
        if( selected.checked == true )
        {
            var extendedCost = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].extendedCost'];
            var receivedQty = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].shippedQty'].value;
            var unitCost = document.purchaseOrderReceiptForm[ 'receivingLineItemList['+ i +'].unitCost'].value;
            if( unitCost.trim() == '' )
            {
                errors = "<li> Please enter valid Unit Cost for LineItem "+ eval( i+1)
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
            extendedCost.value = (receivedQty * unitCost).toFixed(2);
            subTotal = subTotal + parseFloat(extendedCost.value);
        }
    }
    document.purchaseOrderReceiptForm[ 'sub_total'].value = subTotal.toFixed(2);
    tax.value = (subTotal*(parseFloat(selectedTaxPercent)/100)).toFixed(2);

    total.value = ( parseFloat(subTotal) + parseFloat( freight.value) + parseFloat(misc.value) + parseFloat(tax.value)).toFixed(2);
    if( parseFloat(tradeDiscount.value) > parseFloat(total.value) )
    {
        errors = '';
        errorIndex.innerHTML = "<li> Trade Discount amount cannot be greater than Subtotal+Freight+Miscellaneous+Tax"
        errorIndex.focus();
        tradeDiscount.value = '0.0';
    }
    else
    {
        total.value = (parseFloat( total.value) - parseFloat(tradeDiscount.value)).toFixed(2);
        if ( document.purchaseOrderReceiptForm['poType'].value == <%=Constants.PO_TYPE_OPEN%> )
        {
            var remainingPOAmount = document.purchaseOrderReceiptForm['remainingPOAmount'].value;
            if ( parseFloat(total.value) > parseFloat(remainingPOAmount) )
            {
                errors = "<li> Warning: PO receipt amount exceeded the Remaining PO Amount"
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
        }
    }


}

function init()
{
    if( lineItemLength > 0 )
    {
        errorIndex = document.getElementById("lineItemErrors");
        var poTaxType = document.purchaseOrderReceiptForm['poTaxType'];
        if( poTaxType .value == "0" || poTaxType.value == "-1" )
        {
            selectedTaxPercent = 0.0;
        }
        else
        {
            selectedTaxPercent = parseFloat(poTaxType.options[ poTaxType.selectedIndex].text.split('-')[1]);
        }
        var newStateText = document.purchaseOrderReceiptForm['newPoState'].style.visibility="hidden";
        var newTaxText = document.purchaseOrderReceiptForm['newPoTax'].style.visibility="hidden";
        calculateTotals();
    }
}

function setValue( element )
{
    prevPrice = element.value;
}

function addNewPoTaxType( element )
{
    var newStateLabel = document.getElementById("newStateLabel");
    var newStateText = document.purchaseOrderReceiptForm['newPoState'];
    var newTaxLabel = document.getElementById("newTaxLabel");
    var newTaxText = document.purchaseOrderReceiptForm['newPoTax'];

    if( element.value == "-1")
    {
        newStateLabel.innerText = "New State:";
        newStateText.style.visibility="visible";
        newTaxLabel.innerText = "New Tax:";
        newTaxText.style.visibility="visible";
        selectedTaxPercent = 0.0;
    }
    else
    {
        newStateLabel.innerText = "";
        newStateText.value="";
        newStateText.style.visibility="hidden";
        newTaxLabel.innerText = "";
        newTaxText.value="";
        newTaxText.style.visibility="hidden";
        if( element.value != "0")
        {
            selectedTaxPercent = parseFloat(element.options[ element.selectedIndex].text.split('-')[1]);
        }
        else
        {
            selectedTaxPercent = 0.0;
        }
    }
    calculateTotals();
}
function newTaxAmountChanged( newTax)
{
    selectedTaxPercent = 0.0;
    if( newTax.value.trim() != '')
    {
        if ( (checkFloat( newTax.value, 'New Tax', 'Y' ) == true) )
        {
            selectedTaxPercent = parseFloat(newTax.value);
        }
    }
    calculateTotals();
}
function reload()
{
    enableFields();
    document.purchaseOrderReceiptForm.action='<%=chipTracContext%>/purchaseOrderReceipt.do?action=edit' ;
	document.purchaseOrderReceiptForm.submit();
}
</script>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TBODY>
    <TR>
	    <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@include file="/jsp/finance/purchase_order_menu.jsp" %>
            <!-- end of the side navigations -->

        <TD bgcolor="#ffffff">
            <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <BR>
<!-- from here your body starts -->
<html:form name="purchaseOrderReceiptForm" type="com.scalar.chiptrack.finance.openpo.forms.PurchaseOrderReceiptForm" action="/purchaseOrderReceipt.do">

        <table border="0" align = "left" width ="100%" >
         <TR>
                <TD WIDTH="100%">
                    <TABLE BORDER="0" WIDTH="100%" HEIGHT="175%">
                        <TR>
                            <TD WIDTH="100%" align = "">
                                <table width="75%"><tr><td><center><FONT id="poErrors" styleClass="NArialL"><b>Purchase Order Receipt Entry</b></FONT></center></td></TR></table>
                            </TD>
                        </TR>
                    </TABLE>
                    <BR>
                    <TABLE BORDER="0" WIDTH="100%" class="NArialL" bordercolor='red'>
						<html:hidden name="purchaseOrderReceiptForm" property="receipt_id"/>
                        <html:hidden name="purchaseOrderReceiptForm" property="purchaseOrder_Id"/>
                        <html:hidden name="purchaseOrderReceiptForm" property="vendor_id"/>
						<%--<html:hidden name="purchaseOrderReceiptForm" property="receipt_Number"/>--%>
                        <html:hidden name="purchaseOrderReceiptForm" property="vendorDocNumber"/>
                        <html:hidden name="purchaseOrderReceiptForm" property="remainingPOAmount"/>
                        <html:hidden name="purchaseOrderReceiptForm" property="poType"/>
                        <TR>
                            <TD colspan = "9">&nbsp;</TD>
                        <TR>
                        <TR><TD colspan = "9"><chiptrack:errors styleClass="NArialL"/></TD><TR>
                        <TR><TD colspan = "9"><chiptrack:info styleClass="NArialL"/></TD><TR>
                        <TR>
                            <TD colspan = "9"><FONT class="NArialL" style="color:red" id="errorIndex"></FONT></TD>
                        </TR>
						<TR>
                            <TD colspan = "9">&nbsp;</TD>
                        <TR>
                        <TR>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="14%">Receipt Number:</TD>
                            <TD WIDTH="17%" align = "left">
                                <logic:greaterThan value="0" property="receipt_id" name="purchaseOrderReceiptForm">
                                    <bean:write name="purchaseOrderReceiptForm" property="receipt_Number"/>
                                    <html:hidden name="purchaseOrderReceiptForm" property="receipt_Number"/>
                                </logic:greaterThan>
                                <logic:lessEqual value="0" property="receipt_id" name="purchaseOrderReceiptForm">
                                    <html:text  name="purchaseOrderReceiptForm" property="receipt_Number" size="14" styleClass="txfield" maxlength="50"/>
                                </logic:lessEqual>
                            </TD>
                            <TD WIDTH="4%">&nbsp;</TD>
                            <TD WIDTH="14%">PO Number:</TD>
                            <TD WIDTH="30%">
                                <bean:write name="purchaseOrderReceiptForm" property="purchaseOrderNumber"/>
                            </TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="14%">Vendor Name:&nbsp;</TD>
                            <TD WIDTH="17%">
                                <bean:write name="purchaseOrderReceiptForm" property="vendorName"/>
                            </TD>
                            <TD WIDTH="4%">&nbsp;</TD>
                            <TD WIDTH="14%">Receipt Date:&nbsp;</TD>
                            <TD WIDTH="25%">
                                <bean:write name="purchaseOrderReceiptForm" property="receiptDate"/>
                            </TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="14%">Invoice Number:&nbsp;</TD>
                            <TD WIDTH="17%">
                                <html:text name="purchaseOrderReceiptForm" property="invoiceNumber" styleClass="txfield" size="14"/>
                            </TD>
                            <TD WIDTH="4%">&nbsp;</TD>

                            <nested:equal value="<%=Integer.toString(Constants.PO_TYPE_OPEN)%>" property="poType">
                                <TD WIDTH="14%">PO Max $:</TD>
                                <TD WIDTH="25%"><bean:write name="purchaseOrderReceiptForm" property="poMaxAmtFormatted"/></TD>
                                <TD WIDTH="14%">&nbsp;</TD>
                            </nested:equal>
                        </TR>
                        <TR>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                            <TD WIDTH="17%">&nbsp;</TD>
                            <TD WIDTH="4%">&nbsp;</TD>

                            <nested:equal value="<%=Integer.toString(Constants.PO_TYPE_OPEN)%>" property="poType">
                                <TD WIDTH="14%" nowrap>Remaining PO $:</TD>
                                <TD WIDTH="25%"><bean:write name="purchaseOrderReceiptForm" property="remainingPOAmountFormatted"/></TD>
                                <TD WIDTH="14%">&nbsp;</TD>
                            </nested:equal>
                        </TR>
                    </TABLE>
                    <BR>
                    <BR>
              <nested:present property="receivingLineItemList">
              <nested:size id="receivingLineItemListSize" property="receivingLineItemList"/>
              <logic:greaterThan name="receivingLineItemListSize" value="0">
                    <TABLE BORDER="0" WIDTH="100%" CLASS="NArialL">
                        <TR>
                            <TD colspan = "9"><font class="NArialL" style="color:red" id="lineItemErrors"></FONT></TD>
                        </TR>
                        <TR>
						    <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Select</FONT>
                            </TD>
                            <TD WIDTH="4%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER">&nbsp;<FONT COLOR="white">Line Item #</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Process Name</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Part Number</FONT>
                            </TD>
                            <TD WIDTH="16%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Description</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Package Type</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Requested Date</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Received Date</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Requested Quantity</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Previous Received Quantity</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Received Quantity</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Unit Cost($)</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Extended Cost($)</FONT>
                            </TD>
                        </TR>
						<nested:iterate id="recevinglineItem" property="receivingLineItemList" type="com.scalar.chiptrack.finance.openpo.ReceivingLineItem" indexId="lineItemIndex">
						<nested:hidden property="purchaseOrderLineItem_Id"/>
						<nested:hidden property="recevingLineItem_Id"/>
						<nested:hidden property="purchaseOrderLineItemNumber"/>
						<nested:hidden property="processStepId"/>
						<TR>
							<TD WIDTH="4%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<nested:notEqual property="recevingLineItem_Id" value="-1">
									<nested:checkbox property="selected" styleClass="txfield" disabled="true"/>
								</nested:notEqual>
								<nested:equal property="recevingLineItem_Id" value="-1">
									<% String jsString = "javascript:selectInventory("+(i)+");"; %>
									<nested:checkbox property="selected" styleClass="txfield" onclick="<%=jsString%>"/>
                                </nested:equal>
							</td>
							<TD WIDTH="4%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<nested:write property="purchaseOrderLineItemNumber"/>
							</TD>
							<TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<nested:write property="processName"/>
                            </TD>
                            <TD WIDTH="10%" BGCOLOR="#DEE1E2" ALIGN="CENTER">
								<nested:write property="partNumber"/>
                            </TD>
                            <TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<nested:textarea property="description" styleClass="txField"   onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"/>
	                        </TD>
                            <TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<nested:write property="packageType"/>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2" nowrap>
								<nested:write property="requestedDate"/>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2" nowrap>
								<nested:text property="receivedDate" size ="11" styleClass="txField" maxlength="10"/>
								<a href="javascript:openCalendar(document.purchaseOrderReceiptForm['receivingLineItemList[<%=i%>].receivedDate'])"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
	                        </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <nested:write property="requestedQuantity"/>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <nested:write property="previouslyShipppedQty"/>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2" nowrap>
                                <nested:text property="shippedQty" styleClass="valuetxfield" size="10"  disabled="true" onblur='calculateTotals()'/>
								<%String  jsMethod = "javascript:lotDataEntry( "+ i + ",'" + recevinglineItem.getPurchaseOrderLineItemNumber() + "')" ; %>
                                <a href="<%=jsMethod%>" onmouseover="window.status='Click here To add Lot Information';return true" onmouseout="window.status='';return true">
									<IMG SRC="<%=chipTracContext%>/jsp/includes/images/arrow.gif" WIDTH="14" HEIGHT="15" ALIGN="center" BORDER="0">
								</a>
                                <%
                                    long orgShippedQty = recevinglineItem.getOrgShippedQty();
                                    long requestedQty = recevinglineItem.getRequestedQuantity();
                                    long prevReceivedQty = recevinglineItem.getPreviouslyShipppedQty();
                                    long allowedShippedQty = ( requestedQty - prevReceivedQty ) + orgShippedQty;
                                %>
                                <input type="hidden" name="allowedShippedQty[<%=i%>]" value="<%=allowedShippedQty%>">
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <nested:text property="unitCost" styleClass="valuetxfield" size="10"  onblur='calculateTotals()' onkeydown="javascript:setValue(this)" onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <nested:text property="extendedCost" styleClass="valuetxfield" size="10" disabled='true'/>
                            </TD>
                        </TR>
                        <% i++;%>
                        </nested:iterate>
                        <TR>
                            <TD width="20%" colspan="9">&nbsp;</TD>
                            <TD WIDTH="20%">&nbsp;</TD>
                            <TD WIDTH="12%">&nbsp;</TD>
                            <TD WIDTH="26%">&nbsp;</TD>
                            <TD WIDTH="8%">&nbsp;</TD>
                        </TR>
                        <TR>
							<TD WIDTH="20%" colspan="11">&nbsp;</TD>
							<TD WIDTH="26%" ALIGN="RIGHT">Sub Total:&nbsp;$</TD>
							<TD WIDTH="8%">
								<html:text property="sub_total" styleClass="valuetxfield" size="10" disabled='true'/>
							<TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="11"></TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Freight:&nbsp;$</TD>
                            <TD WIDTH="8%"><html:text property="frieght" styleClass="valuetxfield" size="10"  onblur='calculateTotals()' onkeydown="javascript:setValue(this)"  onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="11"></TD>
                            <TD WIDTH="26%" ALIGN="RIGHT" nowrap>Trade Discount&nbsp;$</TD>
                            <TD WIDTH="8%"><html:text property="trade_Discount" styleClass="valuetxfield" size="10"  onblur='calculateTotals()' onkeydown="javascript:setValue(this)"  onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD WIDTH="40%" colspan="11"></TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Miscellaneous:&nbsp;$</TD>
                            <TD WIDTH="8%"><html:text property="miscellaneous" styleClass="valuetxfield" size="10"  onblur='calculateTotals()' onkeydown="javascript:setValue(this)"  onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
							<TD WIDTH="40%" colspan="2"></TD>
							<TD WIDTH="40%" colspan="2" align="right">PO Tax State:</TD>
							<TD WIDTH="40%" align="left">
                                <html:select name="purchaseOrderReceiptForm" property="poTaxType" styleClass="txfield" onchange="javascript:addNewPoTaxType(this);">
<%--                                <html:select name="purchaseOrderReceiptForm" property="poTaxType" styleClass="txfield">                                --%>
                                    <html:option value="0" >Non Taxable</html:option>
                                    <html:options collection="poTaxTypes" property="value" labelProperty="label" />
                                    <html:option value="-1">Others</html:option>
                                </html:select>
							</TD>
                            <TD WIDTH="26%" ALIGN="RIGHT" colspan="7">Tax:&nbsp;$</TD>
                            <TD WIDTH="8%"><html:text property="tax" styleClass="valuetxfield" size="10" disabled="true"/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="2">&nbsp;</TD>
							<TD WIDTH="40%" colspan="2" align="right" id="newStateLabel"></TD>
							<TD WIDTH="40%" colspan="1" align="left" id="newStateText"><input type="text" class="txfield" size="15" name="newPoState" onblur ="javascript:document.purchaseOrderReceiptForm.newPoTax.focus();" maxlength="25" /></TD>
                            <TD WIDTH="26%" colspan="7" ALIGN="RIGHT">Order Total:&nbsp;$</TD>
                            <TD WIDTH="8%"><html:text property="total" styleClass="valuetxfield" size="10" disabled='true'/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="2">&nbsp;</TD>
							<TD WIDTH="40%" colspan="2" align="right" id="newTaxLabel"></TD>
							<TD WIDTH="40%" colspan="1" align="left" id="newTaxText"><input type="text" class="txfield" size="15" name="newPoTax" onkeypress="javascript:restrictCharacters(this,3,2)" onkeyup="javascript:restrictAmt(this,3,2)" onblur="javascript:newTaxAmountChanged(this)" maxlength="6" /></TD>
                            <TD colspan="7">&nbsp;</TD>
                            <TD>&nbsp;</TD>
                            <TD>&nbsp;</TD>
                    </TR>
        </logic:greaterThan>
        </nested:present>
                    <TR>
                        <TD width="20%" colspan="11">&nbsp;</TD>
						<TD WIDTH="20%">&nbsp;</TD>
						<TD WIDTH="12%">&nbsp;</TD>
						<TD WIDTH="8%">&nbsp;</TD>
                    </TR>
        <nested:equal value="<%=Integer.toString(Constants.PO_TYPE_OPEN)%>" property="poType">
                    <TR>
                        <TD width="20%" colspan="11" class="NArialL"><a href="javascript:openLotDataEntry();">Add Receipt Lot Information</a></TD>
                        <TD WIDTH="20%">&nbsp;</TD>
                        <TD WIDTH="12%">&nbsp;</TD>
						<TD WIDTH="8%">&nbsp;</TD>
                    </TR>
        </nested:equal>
                    <TR>
                        <TD width="20%" colspan="11">&nbsp;</TD>
						<TD WIDTH="20%">&nbsp;</TD>
						<TD WIDTH="12%">&nbsp;</TD>
						<TD WIDTH="8%">&nbsp;</TD>
                    </TR>
	        <TR align = "center" border="0">
            <TD bgColor="" align="center" colspan = '10'>
                <A href="javascript:confirmPO()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Save Purchase Order Receipt';return true" onmouseout="window.status='';return true" title="Click to Save Purchase Order Receipt"></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <A href="javascript:document.purchaseOrderReceiptForm.reset();init();" onMouseOver="window.status='Click to Reset the Receipt Information';return true" onMouseOut="window.status='';return true" title="Click to Reset the Receipt Information"><IMG border=0 src="<%=chipTracContext%>/jsp/includes/images/reset.gif"></a>
            </TD>
			<TD>&nbsp;</TD>
			<TD>&nbsp;</TD>
			<TD>&nbsp;</TD>
         </TR>

        </TABLE>

                    <BR>
                </TD>
           </TR>
          </TABLE>
			<script language="javascript">
				var lineItemLength = <%=i%>;
			</script>
</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>